<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
	use HasDateTimeFormatter;   
	
	public $fillable = ['agent_id','openid','video_id','no','transaction_id','price','agent_price','paid_at','appid','type','mch_id','valid','ip','ua','is_deduct'];

	public function scopePaid($query){
		return $query->where('valid',1)->whereNotNull('paid_at');
	}

	public function agent(){
		return $this->belongsTo(Agent::class);
	}
}
